package com.example.notekeep;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.util.TypedValue;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class MainActivity extends Activity {
	
	List<String> edt_list = new ArrayList<String>();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}
	
	// add click
	public void AddClick(View view){
		setContentView(R.layout.add);
	}
	// list click
	public void ListClick(View view){
		LinearLayout ll = new LinearLayout(this);
		ll.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.main_background));
		ll.setOrientation(LinearLayout.VERTICAL);
		ll.setPadding(0,2,0,0);
		
		//add button to return to main 
		Button b = new Button(this);
		b.setText("Return");
		b.setLayoutParams(new LayoutParams(
		        ViewGroup.LayoutParams.WRAP_CONTENT,
		            ViewGroup.LayoutParams.WRAP_CONTENT));
		b.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	setContentView(R.layout.activity_main);
                // Perform action on click
            }
        });
		ll.addView(b);
		
		if(edt_list.size() != 0)
			addLine(ll);
		
		
		for(int i= 0; i <edt_list.size();i++){
			TextView t = new TextView(this);
			String output = new String();
			int j = i + 1;
			output = j + "." + edt_list.get(i);
			t.setText(output);
			t.setTextSize(TypedValue.COMPLEX_UNIT_PX,24);
			ll.addView(t);
			
			
			//add a black line
			addLine(ll);
		}
		
		
		
		setContentView(ll);
		
	}
	// done click
	public void DoneClick(View view){
		
		//store the string
		EditText edt = (EditText)findViewById(R.id.edit);
		String s = edt.getText().toString();
		if(!s.equals("")){
			edt_list.add(s);
		}
		setContentView(R.layout.activity_main);
		
	}

	public void addLine(LinearLayout ll){
		View v = new View(this);
        v.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, 2));
        v.setBackgroundColor(Color.parseColor("#000000"));
        ll.addView(v);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
